package com.xtaller.common.bean;

import com.alibaba.fastjson.JSONObject;
import com.xtaller.common.convert.J;

/**
 * @author Taller
 * @create 2018-04-13 17:28
 */
public class CacheInfo {
    private Object data;           // 用户数据
    private String ios;            // jwt数据 2
    private String android;        // jwt数据 1
    private String pc;             // jwt数据 3
    private String app;            // jwt数据 4
    private String other;          // jwt数据 5


    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String getIos() {
        return ios;
    }

    public void setIos(String ios) {
        this.ios = ios;
    }

    public String getAndroid() {
        return android;
    }

    public void setAndroid(String android) {
        this.android = android;
    }

    public String getPc() {
        return pc;
    }

    public void setPc(String pc) {
        this.pc = pc;
    }

    public String getOther() {
        return other;
    }

    public void setOther(String other) {
        this.other = other;
    }

    public String getApp() {
        return app;
    }

    public void setApp(String app) {
        this.app = app;
    }

    /**
     * 设置平台认证信息
     * */
    public void setJwt(int platform,String jwt){
        switch (platform){
            case 1:
                setAndroid(jwt);
                break;
            case 2:
                setIos(jwt);
                break;
            case 3:
                setPc(jwt);
                break;
            case 4:
                setApp(jwt);
                break;
            case 5:
                setOther(jwt);
                break;
        }
    }
    /**
     * 校验平台认证信息
     * */
    public JSONObject checkJwt(int platform,String jwt){
        JSONObject object = new JSONObject();
        object.put("check", true);
        object.put("message", "验证通过");
        switch (platform){
            case 1:
                if(!getAndroid().equals(jwt)){
                    object.put("check", false);
                    object.put("message", "Android签名过期!");
                }
                break;
            case 2:
                if(!getIos().equals(jwt)){
                    object.put("check", false);
                    object.put("message", "IOS签名过期!");
                }
                break;
            case 3:
                if(!getPc().equals(jwt)){
                    object.put("check", false);
                    object.put("message", "PC签名过期!");
                }
                break;
            case 4:
                if(!getApp().equals(jwt)){
                    object.put("check", false);
                    object.put("message", "移动设备签名过期!");
                }
                break;
            case 5:
                if(!getOther().equals(jwt)){
                    object.put("check", false);
                    object.put("message", "签名过期!");
                }
                break;
        }
        return object;
    }
}
